// ============================== 导入依赖 ============================== //

import * as echarts from 'echarts'

const COLOR = [
  new echarts.graphic.LinearGradient(0, 0, 0, 1, [
    { offset: 0, color: '#F64751' },
    { offset: 1, color: '#F64751' },
  ]),
  new echarts.graphic.LinearGradient(0, 0, 0, 1, [
    { offset: 0, color: '#01CC93' },
    { offset: 1, color: '#01CC93' },
  ]),
  new echarts.graphic.LinearGradient(0, 0, 0, 1, [
    { offset: 0, color: '#FFA904' },
    { offset: 1, color: '#FFA904' },
  ]),
]

// ============================== 导出配置 ============================== //

export default {
  grid: {
    top: 40,
    left: 10,
    right: 16,
    bottom: 0,
    containLabel: true,
  },

  legend: {
    top: 6,
    right: 0,
    icon: 'roundRect',
    itemWidth: 16,
    itemHeight: 4,
    itemGap: 20,
  },

  xAxis: {
    data: [],
    axisTick: {
      show: false,
    },
    axisLabel: {
      color: '#666',
      formatter(value) {
        return value.slice(-5)
      },
    },
    axisLine: {
      lineStyle: {
        color: '#999',
      },
    },
  },

  yAxis: {
    axisLabel: {
      color: '#666',
    },
    axisTick: {
      show: false,
    },
    splitLine: {
      show: false,
    },
  },

  tooltip: {
    trigger: 'axis',
    axisPointer: {
      type: 'cross',
      label: {
        backgroundColor: '#6a7985',
      },
    },
  },

  series: [
    {
      name: '峰电量',
      type: 'bar',
      stack: '电量',
      data: [],
      barWidth: 16,
      label: {
        show: false,
        position: 'top',
        distance: 2,
      },
      itemStyle: {
        color: COLOR[0],
      },
    },
    {
      name: '谷电量',
      type: 'bar',
      stack: '电量',
      data: [],
      barWidth: 16,
      label: {
        show: false,
        position: 'top',
        distance: 2,
      },
      itemStyle: {
        color: COLOR[1],
      },
    },
    {
      name: '平电量',
      type: 'bar',
      stack: '电量',
      data: [],
      barWidth: 16,
      label: {
        show: false,
        position: 'top',
        distance: 2,
      },
      itemStyle: {
        color: COLOR[2],
      },
    },
  ],
}
